{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn import datasets"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "iris = datasets.load_iris()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['target_names', 'data', 'DESCR', 'feature_names', 'target']"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(iris.keys())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "X = iris[\"data\"][:, 3:]  # petal width"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "y = (iris[\"target\"] == 2).astype(np.int)  # 1 if Iris-Virginica, else 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn.linear_model import LogisticRegression"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "LogisticRegression(C=1.0, class_weight=None, dual=False, fit_intercept=True,\n",
       "          intercept_scaling=1, max_iter=100, multi_class='ovr', n_jobs=1,\n",
       "          penalty='l2', random_state=None, solver='liblinear', tol=0.0001,\n",
       "          verbose=0, warm_start=False)"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "log_reg = LogisticRegression()\n",
    "log_reg.fit(X, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "X_new = np.linspace(0, 3, 1000).reshape(-1, 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "y_proba = log_reg.predict_proba(X_new)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xd4VMX+x/H3JCQQekkiEFCKFCnSAgRBpSkkSIcYmlyK\niJeiqFy8XsFef2CnSBUUTUJATJCOQRAQCb1DCB2E0IshIcn8/pgAEYEsYbNnd/N9Pc8+2XKy53M8\n+GWYM2dGaa0RQgjhXjysDiCEEML+pLgLIYQbkuIuhBBuSIq7EEK4ISnuQgjhhqS4CyGEG5LiLoQQ\nbkiKuxBCuCEp7kII4YbyWLVjX19fXa5cOat2L4QQLmn9+vWntNZ+WW1nWXEvV64ccXFxVu1eCCFc\nklLqoC3bSbeMEEK4ISnuQgjhhrIs7kqpqUqpk0qpbbf5XCmlvlBKxSultiil6to/phBCiLthS8v9\nG6D1HT4PBiplPAYA4+89lhBCiHuRZXHXWq8Aztxhk/bADG38DhRVSpWyV0AhhBB3zx597gHA4Uyv\nj2S89w9KqQFKqTilVFxiYqIddi2EEOJWHHpBVWs9UWsdqLUO9PPLcpimEEKIbLLHOPejQNlMr8tk\nvJdjli2DXbvA3x/8/MxPf38oUQKUysk9CyGEa7BHcY8GBiulwoGGwHmt9XE7fO9thYfD5Ml/fy9f\nPvjrL/N85EhYs8YU/NKlISAAypeHDh3M51rLXwJCCPeWZXFXSv0ANAV8lVJHgDcALwCt9QR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\npm1CgAWAAoKAtVbnvodjaQrMszqrDcfyGFAX2Habz13inNh4LK5yTkoBdTOeFwL2uPD/K7Yci6uc\nFwUUzHjuBawFghx1Xpy55X59BSitdQpwbQWozK6vAKW1/h0oqpQq5eigNrDlWFyC1noFcOYOm7jK\nObHlWFyC1vq4zlizWGt9EdjJPxfLcYnzYuOxuISM/9aXMl56ZTxuvsiZY+fFmYu7O60AZWvORzL+\nabZAKVXdMdHszlXOia1c6pwopcoBdTCtxMxc7rzc4VjARc6LUspTKbUJOAks0Vo77LzYNCukcIgN\nwP1a60tKqRBgLmbBcWEdlzonSqmCwGzgRa31Bavz3IssjsVlzovWOg2orZQqCvyolKqhtb7lNR57\nc+aWu91WgHICWebUWl+49k84baZY9lJK+Touot24yjnJkiudE6WUF6YYztRaz7nFJi5zXrI6Flc6\nL9dorc8BsUDrmz7KsfPizMXdnVaAyvJYlFIllVIq43kDzLk57fCk985VzkmWXOWcZGScAuzUWn9y\nm81c4rzYciwudF78MlrsKKV8gCeAXTdtlmPnxWm7ZbQbrQBl47F0AZ5XSqUCSUCYzric7kyUUj9g\nRiv4KqWOAG9gLhS51DkBm47FJc4J0BjoBWzN6N8FeA24H1zuvNhyLK5yXkoB05VSnpi/gCK11vMc\nVcPkDlUhhHBDztwtI4QQIpukuAshhBuS4i6EEG5IirsQQrghKe5CCOGGpLgLIYQbkuIuhBBuSIq7\nEEK4of8HR/ft6S881IAAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0xd116f8c588>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(X_new, y_proba[:, 1], \"g-\", label=\"Iris-Virginica\")\n",
    "plt.plot(X_new, y_proba[:, 0], \"b--\", label=\"Not Iris-Virginica\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1, 0])"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "log_reg.predict([[1.7], [1.5]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 1])"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "log_reg.predict([[1.3], [1.9]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "X = iris[\"data\"][:, (2,3)]  # petal length, petal width"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "y = iris[\"target\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "LogisticRegression(C=10, class_weight=None, dual=False, fit_intercept=True,\n",
       "          intercept_scaling=1, max_iter=100, multi_class='multinomial',\n",
       "          n_jobs=1, penalty='l2', random_state=None, solver='lbfgs',\n",
       "          tol=0.0001, verbose=0, warm_start=False)"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "softmax_reg = LogisticRegression(multi_class=\"multinomial\", solver=\"lbfgs\", C=10)\n",
    "softmax_reg.fit(X, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([2])"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "softmax_reg.predict([[5, 2]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[  6.33134077e-07,   5.75276067e-02,   9.42471760e-01]])"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "softmax_reg.predict_proba([[5, 2]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.3"
  },
  "toc": {
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
